package main

import (
	"github.com/gin-gonic/gin"
)

func main() {
	router := gin.Default()

	router.POST("/download", func(context *gin.Context) {
		//前后端不分离
		context.Header("Content-Type", "application/octet-stream") //文件流
		context.Header("Content-Disposition", "attachment; filename="+"xx.png")
		context.Header("content-Transfer-Encoding", "binary")
		context.File("uploads/12.png")
		//前后端分离  下载由前端程序调用  后端只返回文件
		context.Header("fileName", "xxx.png")
		context.File("uploads/12.png")

		context.JSON(200, gin.H{"msg": "上传成功"})
	})

	router.Run(":8080")
}
